package top.hkyzf.study.leetcode.array;

import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;

/**
 * @author zhufeng
 * @version 1.0
 * @date 2022-1-20 17:58
 */
public class 有序数组的平方_977 {
    public int[] sortedSquares(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            nums[i] = nums[i] * nums[i];
        }
        Arrays.sort(nums);
        return nums;
    }

    @Test
    public void testSortedSquares () {
        int[] nums = {-4,-1,0,3,10};
        int[] squares = sortedSquares(nums);
        System.out.println(Arrays.toString(squares));
    }
}
